package com.lagou;

import com.lagou.bean.ConsumerComponent;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;


public class AnnotationConsumerMain {
    public static void main(String[] args) throws IOException, InterruptedException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        ConsumerComponent client = context.getBean(ConsumerComponent.class);
        for (int i=0;i<4; i++){
            new Thread(()->{
                while(true){
                    client.callA();
                }
            }).start();
        }
        for (int i=0;i<4; i++){
            new Thread(()->{
                while(true){
                    client.callB();
                }
            }).start();
        }
        for (int i=0;i<4; i++){
            new Thread(()->{
                while(true){
                    client.callC();
                }
            }).start();
        }
        System.in.read();
    }

    @Configuration
    @PropertySource("classpath:/dubbo-consumer.properties")
    //@EnableDubbo(scanBasePackages = "com.lagou.bean")
    @ComponentScan("com.lagou.bean")
    @EnableDubbo
    static class ConsumerConfiguration {

    }
}
